import i18n from 'i18next'
import enUS from '@/locales/en-US'
import zhUS from '@/locales/zh-CN'
import { defaultSetting } from '@/default-setting'

i18n.init({
  resources: {
    en: {
      translation: enUS
    },
    zh: {
      translation: zhUS
    }
  },
  lng: defaultSetting.defaultLang || 'zh',
  fallbackLng: defaultSetting.defaultLang || 'zh',
  interpolation: {
    escapeValue: false
  }
})

export const t = (key: string): string => {
  return i18n.t(key) || key
}

export { i18n }
